﻿#pragma once
#include "MyHeadFile.h"

// CTreeListDlg 对话框

class CTreeListDlg : public CDialogEx
{
	DECLARE_DYNAMIC(CTreeListDlg)

public:
	CTreeListDlg(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~CTreeListDlg();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DIALOG6 };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()

private:
	char** m_pFileData = NULL;       //数据

	//根据RVA计算FA
    DWORD RVATOFA(DWORD dwRVA);

    //展开树控件
    void ExpandTreeCtrl(HTREEITEM hTreeItem);

    //清空ListCtrl
    void ClearListCtrl();

	//设置List表头
	void SetListCtrlColumn();

    //将数字转换为字符串
    CString IntToString(DWORD nData, DWORD nLen);

    //获取变量Size
    CString GetVariableSizeToString(DWORD nLen);

	//打印 DIRECTORY 目录值
	void ShowDirectory(_RESOURCE_INFO* pResInfo);

    //打印 DIRECTORY_ENTRY 目录值
    void ShowDirectoryEntry(_RESOURCE_INFO* pResInfo);

    //打印 DATA_ENTRY 目录值
    void ShowDataEntry(_RESOURCE_INFO* pResInfo);

public:
	void SetFileData(char** pFileData);

	void ShowResourceData();

	void ShowAllData(PIMAGE_RESOURCE_DIRECTORY_ENTRY pDirEntry, HTREEITEM hRoot, int nItem, DWORD SecOffset);
public:
	CTreeCtrl m_TreeCtrl;
	CListCtrl m_ListCtrl;
	afx_msg void OnMove(int x, int y);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	virtual BOOL OnInitDialog();
	afx_msg void OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult);
};
